package pers.cz.service.impl;

import org.springframework.stereotype.Service;
import pers.cz.commons.datasource.DbKeyHolder;
import pers.cz.mapper.ImsJsonSoap0Mapper;
import pers.cz.mapper.PostgirlMapper;
import pers.cz.mapper.SequenceMapper;
import pers.cz.model.ImsJsonSoap0;
import pers.cz.model.Postgirl;
import pers.cz.model.Sequence;
import pers.cz.spring.SpringContextUtil;

import java.util.Date;

/**
 * @program: PostGirl-panent
 * @description:
 * @author: Cheng Zhi
 * @create: 2023-02-25 21:42
 **/
@Service
public class TestService {

    public void insertDev() {
        ImsJsonSoap0 imsJsonSoap0 = new ImsJsonSoap0();
        imsJsonSoap0.setBusiCode(99999);
        imsJsonSoap0.setClientId("cztest");
        imsJsonSoap0.setInputSoap("哈哈哈哈");
        imsJsonSoap0.setJsonId("qwertyuiopqwer");
        DbKeyHolder.setDbKey("dev");
        SpringContextUtil.getBean(ImsJsonSoap0Mapper.class).insertSelective(imsJsonSoap0);
        DbKeyHolder.clearDbKey();
    }

    public void insertMaster() {
        Postgirl postgirl = new Postgirl();
        postgirl.setCreateDate(new Date());
        postgirl.setAccountExpired("tt");
        postgirl.setCredentialsExpired("bb");
        postgirl.setEmail("tt");
        postgirl.setEnabled("true");
        postgirl.setLocked("2");
        postgirl.setPassWord("were");
        postgirl.setPhoneId("121231");
        postgirl.setRealName("cz");
        postgirl.setUserId(999);
        DbKeyHolder.setDbKey("master");
        SpringContextUtil.getBean(PostgirlMapper.class).insertSelective(postgirl);
    }

    public Sequence select(String sequenceName) {
        Sequence sequence = SpringContextUtil.getBean(SequenceMapper.class).selectByPrimaryKey(sequenceName, "1");
        return sequence;
    }
}
